//
// Created by xili on 2024/9/3 21:29.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int minimumRounds(vector<int> &tasks) {
        unordered_map<int, int> cnt;
        for (int t: tasks) {
            cnt[t]++;
        }
        int res = 0;
        for (auto [_, v]: cnt) {
            if (v == 1) {
                return -1;
            } else if (v % 3 == 0) {
                res += v / 3;
            } else {
                res += v / 3 + 1;
            }
        }
        return res;
    }
};